package com.aeye.chatserver;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class HttpModelUtil {

    public static String modelQuery(String input) {
        HttpRequest httpRequest = HttpUtil.createPost("http://192.168.16.155/v1/chat-messages");
        Map<String, String> params = new HashMap<>();
        params.put("Authorization", "Bearer app-VbnJATTc3bGxrzbzTA4qNyRx");
        params.put("Content-Type", "application/json");
        httpRequest.addHeaders(params);
        JSONObject jsonObject = new JSONObject();
        JSONObject inputJson = new JSONObject();
        jsonObject.put("inputs", inputJson);
        jsonObject.put("query", input);
        jsonObject.put("response_mode", "blocking");
        jsonObject.put("conversation_id", "");
        jsonObject.put("user", "abc-123");
        System.out.println(jsonObject.toString());
        return httpRequest.body(jsonObject.toString()).execute().body();
    }
}
